package org.base;

import java.util.ArrayList;
import java.util.List;
import javax.inject.Named;
import javax.faces.view.ViewScoped;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import javax.inject.Inject;

@Named(value = "expedienteController")
@ViewScoped
public class ExpedienteController extends AbstractController<Expediente> {

    @Inject
    private TipoExpedienteController tipoExpedienteIdController;
    @Inject
    private BarrioController barrioIdController;
    
    private List<Pase> pasesAsociados = new ArrayList<>();

    public ExpedienteController() {
        // Inform the Abstract parent controller of the concrete Expediente?cap_first Entity
        super(Expediente.class);
    }

    /**
     * Resets the "selected" attribute of any parent Entity controllers.
     */
    public void resetParents() {
        tipoExpedienteIdController.setSelected(null);
        barrioIdController.setSelected(null);
    }

    /**
     * Sets the "selected" attribute of the TipoExpediente controller in order
     * to display its data in a dialog. This is reusing existing the existing
     * View dialog.
     *
     * @param event Event object for the widget that triggered an action
     */
    public void prepareTipoExpedienteId(ActionEvent event) {
        if (this.getSelected() != null && tipoExpedienteIdController.getSelected() == null) {
            tipoExpedienteIdController.setSelected(this.getSelected().getTipoExpedienteId());
        }
    }

    /**
     * Sets the "selected" attribute of the Barrio controller in order to
     * display its data in a dialog. This is reusing existing the existing View
     * dialog.
     *
     * @param event Event object for the widget that triggered an action
     */
    public void prepareBarrioId(ActionEvent event) {
        if (this.getSelected() != null && barrioIdController.getSelected() == null) {
            barrioIdController.setSelected(this.getSelected().getBarrioId());
        }
    }

    public List<Pase> getPasesAsociados() {
        return pasesAsociados;
    }

    public void setPasesAsociados(List<Pase> pasesAsociados) {
        this.pasesAsociados = pasesAsociados;
    }
    
    
}
